package cn.xiaohaoo.process;

import java.io.*;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 生成数据集标签
 */
public class GeneratorDatasetsLabel {
    public static void main(String[] args) throws IOException {
        File file=new File("./datasets/dataset4");
        File lableFile=new File("./datasets/medicine_name-lable.txt");
        File medicineFile=new File("./datasets/lable-medicine_name.txt");
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(lableFile)));
        BufferedWriter medicineNameWriter =
                new BufferedWriter(new OutputStreamWriter(new FileOutputStream(medicineFile)));
        AtomicInteger index= new AtomicInteger();
        Arrays.stream(file.listFiles()).forEach(v-> {
            try {
                bufferedWriter.write(v.getName()+","+index.get());
                bufferedWriter.newLine();
                medicineNameWriter.write(index.get()+","+v.getName());
                medicineNameWriter.newLine();
                index.getAndIncrement();
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
        bufferedWriter.flush();
        medicineNameWriter.flush();
        bufferedWriter.close();
        medicineNameWriter.close();
        System.out.println(index.get());
    }
}
